home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
earcd
/
dev
/
obero
/
dialogs.lha
/
oberonv4
/
system1
/
DialogGroupBoxes.Mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1995-12-30
|
9KB
|
211 lines
Syntax10.Scn.Fnt
Syntax10i.Scn.Fnt
StampElems
Alloc
30 Dec 95
Syntax10b.Scn.Fnt
MODULE DialogGroupBoxes;
(** Markus Knasm
ller 30 Jun 94 -
IMPORT DialogFrames, Dialogs, DialogStaticTexts, DialogTexts, Display, Display1, Files,
Fonts, GraphicUtils, In, Oberon, Printer, TextFrames, Texts, Viewers;
CONST W* = 100; H* = 100; black = 15; white = 0; MM = 1; CR = 0DX;
TYPE
Item* = POINTER TO ItemDesc;
ItemDesc* = RECORD(Dialogs.ObjectDesc)
fnt-: Fonts.Font; (** the font with which the text is shown *)
s-: ARRAY 64 OF CHAR; (** the text which is shown *)
END;
VAR w0: Texts.Writer;
PROCEDURE (g: Item) Draw* (x, y: INTEGER; f: Display.Frame);
(** displays the object at (x, y) in frame f *)
VAR mode, w, h, gx, gy, cx, yh: INTEGER;
PROCEDURE Max (x, y: INTEGER): INTEGER;
BEGIN
IF x > y THEN RETURN x ELSE RETURN y END
END Max;
BEGIN
g.GetDim (gx, gy, w, h); INC (y);
DEC (w, 2); DEC (h, 5); cx := 0;
IF (h < 0) OR (w < 0) THEN
Display1.Line (f, black, x, y, x + Max (w, 0), y + Max (h, 0), Display.paint);
RETURN
END;
IF g.selected THEN mode := Display.invert ELSE mode := Display.paint END;
yh := y + h - g.fnt.maxY - g.fnt.minY;
IF g.s = "" THEN cx := w
ELSIF yh > y THEN GraphicUtils.DrawString (f, g.s, x + 3, yh, w - 4, g.fnt, mode, GraphicUtils.center, cx)
END;
Display1.Line (f, black, x, y, x + w, y, mode); Display1.Line (f, black, x, y, x, y + h, mode);
Display1.Line (f, black, x + w, y, x + w, y + h, mode);
Display1.Line (f, white, x, y - 1, x + w, y - 1, mode); Display1.Line (f, white, x + 1, y + 1, x + 1, y + h, mode);
Display1.Line (f, white, x + w + 1, y, x + w + 1, y + h, mode);
IF cx > 0 THEN
Display1.Line (f, black, x, y + h, x + cx, y + h, mode);
Display1.Line (f, black, x + w - cx, y + h, x + w, y + h, mode);
Display1.Line (f, white, x + 1, y + h - 1, x + cx, y + h - 1, mode);
Display1.Line (f, white, x + w - cx, y + h - 1, x + w - 1, y + h - 1, mode)
END;
END Draw;
PROCEDURE (g:Item) Print* (x, y: INTEGER);
(** prints the object at printer coordinates (x, y) *)
VAR w, h, gx, gy, yh, cx: INTEGER; fnth: LONGINT;
BEGIN
g.GetPDim (gx, gy, w, h);
DEC (w, 2); DEC (h, 5); IF h < 0 THEN RETURN END;
Printer.Line (x, y, x + w, y); Printer.Line (x, y, x, y + h);
Printer.Line (x + w, y, x + w, y + h);
fnth := (g.fnt.maxY + g.fnt.minY) * Dialogs.dUnit DIV Dialogs.pUnit;
yh := y + h - SHORT (fnth);
IF yh > y THEN GraphicUtils.PrintString (g.s, x + 3, yh, w - 4, g.fnt, GraphicUtils.center, cx) END;
IF cx > 0 THEN
Printer.Line (x, y + h, x + cx, y + h); Printer.Line (x + w - cx, y + h, x + w, y + h);
END
END Print;
PROCEDURE (g: Item) Copy* (VAR dup: Dialogs.Object);
(** allocates dup and makes a deep copy of o. Before calling this methode dup should be equal NIL *)
VAR x: Item;
BEGIN
IF dup = NIL THEN NEW (x); dup := x ELSE x := dup(Item) END;
g.Copy^ (dup); x.fnt := g.fnt; COPY (g.s, x.s);
END Copy;
PROCEDURE (g: Item) Load* (VAR r: Files.Rider);
(** reads the object from rider r *)
VAR fntname: ARRAY 32 OF CHAR;
BEGIN g.Load^ (r); Files.ReadString (r, fntname); g.fnt := Fonts.This (fntname); Files.ReadString (r, g.s) ;
END Load;
PROCEDURE (g: Item) Store* (VAR r: Files.Rider);
(** writes the object to rider r *)
BEGIN g.Store^ (r); Files.WriteString (r, g.fnt.name); Files.WriteString (r, g.s);
END Store;
PROCEDURE (g: Item) SetFont* (fnt: Fonts.Font);
(** sets the font with which the text is shown *)
BEGIN g.Hide; g.fnt := fnt; g.Restore; IF g.panel # NIL THEN g.panel.MarkMenu END
END SetFont;
PROCEDURE (g: Item) SetString* (s: ARRAY OF CHAR);
(** sets the text which is shown *)
BEGIN g.Hide; COPY (s, g.s); g.Restore; IF g.panel # NIL THEN g.panel.MarkMenu END
END SetString;
PROCEDURE (g: Item) Handle* (f: Display.Frame; VAR m: Display.FrameMsg);
(** handles messages which were sent to frame f *)
VAR t: Texts.Text;
BEGIN
g.Handle^ (f, m);
WITH f: DialogFrames.Frame DO
WITH m: Oberon.InputMsg DO
IF m.id = Oberon.track THEN
IF (m.keys = {MM}) & (g.cmd[0] # 0X) THEN
DialogTexts.GetParText (g.par, g.panel, t);
g.CallCmd (f, Viewers.This (m.X, m.Y), TextFrames.Text (""))
ELSE Oberon.DrawCursor (Oberon.Mouse, Oberon.Arrow, m.X, m.Y)
END
END
ELSE
END
ELSE
END
END Handle;
PROCEDURE WriteToObjectStr (o: DialogTexts.Item; VAR p: Dialogs.Panel; n: ARRAY OF CHAR);
VAR t: Texts.Text;
BEGIN
t := o.GetText (); Texts.WriteString (w0, n); Texts.Append (t, w0.buf);
END WriteToObjectStr;
PROCEDURE (g: Item) Edit*;
(** opens a dialog for editing the properties of the object *)
VAR on: Dialogs.Object; os, string: DialogTexts.Item; s: DialogStaticTexts.Item; p: Dialogs.Panel; t1: Texts.Text; fnt: Fonts.Font;
BEGIN
g.Edit^ (); p := Dialogs.editPanel;
NEW (string); string.Init;
string.SetName ("string"); string.SetDim (245, -30, 140, 19, FALSE); p.Insert (string, FALSE);
(* ---- *) ASSERT (Dialogs.res = Dialogs.ok);
NEW (s); s.Init; s.SetDim (196, -30, 40, 20, FALSE);
s.SetString ("String"); fnt := Fonts.This ("Syntax10.Scn.Fnt"); s.SetFont (fnt);
p.Insert (s, FALSE);
(* ---- *) ASSERT (Dialogs.res = Dialogs.ok);
WriteToObjectStr (string, p, g.s);
t1 := string.GetText (); Texts.ChangeLooks (t1, 0, t1.len, {0}, g.fnt, 0, 0);
END Edit;
PROCEDURE (g: Item) Update* (p: Dialogs.Panel);
(** sets the properties of the object to the values defined in the dialog p opened with Edit *)
VAR os: Dialogs.Object; t1: Texts.Text; r: Texts.Reader; ch: CHAR; str: ARRAY 64 OF CHAR; i: INTEGER;
BEGIN
g.Update^ (p);
os := p.NamedObject ("string"); t1 := os(DialogTexts.Item).GetText ();
Texts.OpenReader (r, t1, 0); Texts.Read (r, ch); i := 0;
IF (r.fnt # NIL) & (r.fnt # g.fnt) THEN g.SetFont (r.fnt) END;
WHILE ~ r.eot DO
str[i] := ch; INC (i); Texts.Read (r, ch);
END;
str[i] := 0X;
IF str # g.s THEN g.SetString (str) END
END Update;
PROCEDURE (g: Item) GetObjects* (VAR obArray: ARRAY OF Dialogs.Object; VAR nofelems: INTEGER);
(** gets all objects which are lying unter the groupbox *)
VAR p: Dialogs.Panel; x, y, w, h: INTEGER;
BEGIN
p := g.panel; g.GetDim (x, y, w, h); p.GetObjects (x, y, w, h, obArray, nofelems);
END GetObjects;
PROCEDURE Insert*;
(** Insert ([name] [x y w h] | ^ ) inserts a groupbox - item in the panel containing the caret position *)
VAR x, y, x1, y1, w, h: INTEGER; g: Item; p: Dialogs.Panel; name: ARRAY 64 OF CHAR; r: Texts.Reader; ch: CHAR;
BEGIN
NEW (g);
DialogFrames.GetCaretPosition (p, x, y);
IF (p # NIL) THEN
g.Init (); In.Open; Texts.OpenReader (r, Oberon.Par.text, 0); Texts.Read (r, ch);
In.Name (name);
IF ~In.Done THEN COPY ("", name); In.Open ELSE g.fnt := r.fnt END;
g.SetName (name);
In.Int (x1); In.Int (y1); In.Int (w); In.Int (h);
IF ~In.Done THEN x1 := x; y1 := y; w := W; h := H
ELSE
IF w < 0 THEN w := W END;
IF h < 0 THEN h := H END
END;
g.SetDim (x1, y1, w, h, FALSE);
g.SetString (name); g.SetFont (Fonts.This ("Syntax10.Scn.Fnt"));
p.Insert (g, TRUE);
ELSE
Dialogs.res := Dialogs.wrongInput
END;
IF Dialogs.res # 0 THEN
Dialogs.Error ("DialogGroupBoxes")
END;
END Insert;
PROCEDURE SetString*;
(** SetString ({ch} | ^) sets the string of the groupbox item at the caret to str *)
VAR o: Dialogs.Object; p: Dialogs.Panel; str: ARRAY 64 OF CHAR; ch: CHAR; i: INTEGER;
BEGIN
In.Open; In.Char (ch); i := 0;
WHILE In.Done & (ch = " ") DO In.Char (ch) END; (* skip leading blanks *)
IF ~ In.Done THEN
Dialogs.res := Dialogs.wrongInput
ELSE
WHILE In.Done & (ch # CR) & (ch # "~") & (i < 63) DO str[i] := ch; INC (i); In.Char (ch) END;
str[i] := 0X;
DialogFrames.FindObject (o, p);
IF (Dialogs.res = Dialogs.ok) & (o IS Item) THEN
o(Item).SetString (str); o(Item).SetFont (Fonts.This ("Syntax10.Scn.Fnt"))
END
END;
IF Dialogs.res # Dialogs.ok THEN Dialogs.Error ("DialogGroupBoxes") END
END SetString;
PROCEDURE GetString*;
(** writes the component s of the groupbox item under the caret to the log viewer *)
VAR o: Dialogs.Object; p: Dialogs.Panel; str: ARRAY 64 OF CHAR;
BEGIN
DialogFrames.FindObject (o, p);
IF Dialogs.res = Dialogs.ok THEN
IF o IS Item THEN
COPY (o(Item).s, str);
Texts.WriteString (w0, "String:"); Texts.WriteString (w0, str); Texts.WriteLn (w0);
Texts.Append (Oberon.Log, w0.buf)
ELSE
Dialogs.res := Dialogs.objectNotFound
END
END;
IF Dialogs.res # Dialogs.ok THEN Dialogs.Error ("DialogStaticTexts") END
END GetString;
BEGIN Texts.OpenWriter (w0)
END DialogGroupBoxes.